#ifndef __LOGIN_H__
#define __LOGIN_H__

#define FALSE                   (0)
#define TRUE                    (1)

enum {
    LOGIN_PARAM_NULL = 1,
    LOGIN_OPEN_FILE_FAIL,
    LOGIN_WRITE_FILE_FAIL,
    LOGIN_ENCIPHER_FAIL,
    LOGIN_DECIPHER_FAIL,
};

#define USER_NAME_LENGTH        (11)
#define USER_ACCOUNT_LENGTH     (11)
#define USER_PASSWORD_LENGTH    (11)

#define ADMIN       0
#define COMMOM      1

#define LOGIN_INFO_FILE    "./lib/user_account.txt"
#define LIB_DIR            "./lib"

struct login_info{
    char is_login;
    char name[USER_NAME_LENGTH];
    char account[USER_ACCOUNT_LENGTH];
    char password[USER_PASSWORD_LENGTH];
};

extern int login_init(void);
extern int user_register(struct login_info *);
extern int user_login(struct login_info *);
extern int user_logout(struct login_info *);
extern int is_admin(struct login_info *);

#endif